﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace SuDokuSolution
{
    public class GraphicalCell
    {
       internal Constants one;

		/// Cell Data
	
        public CellData cellData;
        
		
		public ArrayList CheckedNbs;		

	
		/// whether to redraw the cell or not
	
		public bool redraw=true;

	
		/// size of the cell
	
		public Size cellSize;

	
		/// size of the sub cell
	
		public Size subCellSize;

	
		/// lacation of the cell
	
		public Point cellLocation;


		/// rectangle to store the drawing area of the cell
		
		public Rectangle cellRect;

		
		/// background brush to be used
	
		public Brush backGroundBrush;

		
		/// flag to draw a nb in error color if an invalid no has been selected
	
		public bool MarkError=false;

        /// return the nb clicked in a cell
        public virtual int getClickedNb(int x,int y)
		{
			int col=(int)(x/subCellSize.Width);
			int row=(int)(y/subCellSize.Height);

			int nb=row*one.nbOfLines+col+1;            			
			
			return nb;
		}
      

      
        /// Processes Mouse double click event 
             
        public virtual void DoubleClick(MouseEventArgs e)
        {
            if (cellData.readOnly)
                return;
            int clickedNb = getClickedNb(e.X - cellLocation.X, e.Y - cellLocation.Y);

            if (cellData.problemNb == one.NoNumber)
                cellData.problemNb = clickedNb;
            else
                cellData.problemNb = one.NoNumber;

            CheckedNbs.Clear();  //clear the marked nbs			
        }


    }
}
